package com.one.consumer.reserve.ui.activity;

import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.one.common.config.RouterPath;
import com.one.common.manager.RouterManager;
import com.one.common.manager.imageloader.ILoader;
import com.one.common.manager.imageloader.LoaderManager;
import com.one.common.model.http.NetConstant;
import com.one.common.utils.list.ListUtils;
import com.one.common.view.widget.MyTitleBar;
import com.one.consumer.BaseActivityC;
import com.one.consumer.R;
import com.one.consumer.reserve.model.bean.ReserveIconBean;
import com.one.common.common.order.extra.ReserveExtra;
import com.one.consumer.reserve.presenter.DEPresenter;
import com.one.consumer.reserve.ui.view.ReserveIconView;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/10/21 下午6:50
 * description ： 装修预约
 **/

@Route(path = RouterPath.DE_RESERVE)
public class DecorationReserveActivity extends BaseActivityC<DEPresenter> implements ReserveIconView{
    @BindView(R.id.iv_bg_1)
    ImageView ivBg1;
    @BindView(R.id.tv_reserve)
    TextView tvReserve;
    @BindView(R.id.rl_1)
    RelativeLayout rl1;
    @BindView(R.id.iv_bg_2)
    ImageView ivBg2;
    @BindView(R.id.tv_case_show)
    TextView tvCaseShow;
    @BindView(R.id.rl_2)
    RelativeLayout rl2;

    private ReserveExtra extra;
    @Override
    protected void initPresenter() {
        mPresenter = new DEPresenter(this,this);
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_decoration_reserve;
    }

    @Override
    protected void initTitle() {
        super.initTitle();
        getMyTitleBar().setMode(MyTitleBar.Mode.BACK_TITLE)
                .setTitleText("装修预约");
    }

    @Override
    public void initData() {
        super.initData();
        extra = (ReserveExtra) getIntent().getSerializableExtra(ReserveExtra.getExtraName());
        mPresenter.getImg();
    }

    @OnClick(R.id.rl_1)
    public void reserve(){
       RouterManager.getInstance().go(RouterPath.ADD_RESERVE_DE,extra);
   }

    @OnClick(R.id.rl_2)
    public void caseList(){
        RouterManager.getInstance().go(RouterPath.CASE_LIST,extra);
    }

    @Override
    public void setIcon(ReserveIconBean bean) {
        if(ListUtils.isNotEmpty(bean.getObject())){
            ILoader.Options options = ILoader.Options.roundOptions(8);
            options.setCenterCrop(true);
            LoaderManager.getLoader().loadNet(ivBg1, NetConstant.IMG_HOST + bean.getObject().get(0).getIcon_img(),
                    options);
            LoaderManager.getLoader().loadNet(ivBg2, NetConstant.IMG_HOST + bean.getObject().get(1).getIcon_img(),
                    options);
        }
    }
}
